class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2023-04-08",
      revision: "99cef8d064e7374e94232e9768abed7753b7eddb"
  version "2023-04-08"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "316948212c6d520c9221fe75255620af7a648cf301f232bfe11e5e845514f793"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "7b5e8c680495cfd92ea735982fe9f5d64799d1704431672a8342120e4b28a0cf"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "574c3f1b6b8b6a5a33f15df73b284c9463e8fcb51965e21a453eca2b0c26027c"
    sha256 cellar: :any_skip_relocation, ventura:        "fc216b1afbbe82631d997de1b578a7ce956d7e855174fad4716c4ad490107a1d"
    sha256 cellar: :any_skip_relocation, monterey:       "13243250e5f4577442de4d6ff0c8247e8d383aad1d638098e250714aeb10385b"
    sha256 cellar: :any_skip_relocation, big_sur:        "f195de7228b5668864a1b4c922df110fe13370669d6e7b481dc7a6f01174c27b"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "36fc6dbdecff4e6a812dcc81cc5c049d52a795da286cd2bd8f32993f282eb881"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
